package 对撞指针;

public class LeetCode11_盛水最多的容器 {
    public int maxArea(int[] height) {
        int left = 0;
        int right = height.length-1;
        int area = 0;
        while(left < right) {
            if(((right-left) * (Math.min(height[left],height[right]))) > area) {
                area = (right-left) * (Math.min(height[left],height[right]));
            }else {
                if(height[left] < height[right]) {
                    left++;
                }else{
                    right--;
                }
            }
        }
        return area;
    }
}
